package com.example.javapoint.threads.join;

class ThreadJoinMethod extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 5; i++) {
            System.out.println(Thread.currentThread().getName() + "-------->" + i);
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class ThreadJoinExample1 {
    public static void main(String[] args) {
        ThreadJoinMethod t1 = new ThreadJoinMethod();
        ThreadJoinMethod t2 = new ThreadJoinMethod();
        ThreadJoinMethod t3 = new ThreadJoinMethod();

        t1.start();
        try {
            t1.join();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        t2.start();
        t3.start();
    }
}
